package com.koron.system.company.controller;

import com.koron.bean.base.Response;
import com.koron.bean.query.PageQuery;
import com.koron.common.core.config.ThreadLocalContext;
import com.koron.system.company.pojo.po.CompanyPO;
import com.koron.system.company.pojo.query.CompanyQuery;
import com.koron.system.company.service.CompanyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.koron.ebs.mybatis.ADOConnection;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "企业信息管理", description = "企业信息管理接口")
@RestController
@RequestMapping("/company")
public class CompanyController {

    @Autowired
    private CompanyService companyService;

    private String getCurrDs(){
        return ThreadLocalContext.get().getCurrDs();
    }

    @ApiOperation(value = "分页查询企业信息", notes = "分页查询企业信息")
    @GetMapping("/page")
    public Response page(PageQuery pageQuery, CompanyQuery companyQuery){

        return ADOConnection.runTask(companyService, "page", Response.class,pageQuery, companyQuery);
    }


    @ApiOperation(value = "保存或更新企业信息", notes = "保存或更新企业信息")
    @PostMapping("/saveOrUpdate")
    public Response save(CompanyPO companyPO){

        return ADOConnection.runTask( companyService, "save", Response.class, companyPO);
    }

    @ApiOperation(value = "删除企业信息", notes = "删除企业信息")
    @GetMapping("/delete")
    public Response delete(Integer id){

        return ADOConnection.runTask(companyService, "delete", Response.class, id);
    }

    @ApiOperation(value = "获取企业信息", notes = "获取企业信息")
    @GetMapping("/get")
    public Response get(CompanyQuery companyQuery){

        return ADOConnection.runTask(companyService, "get", Response.class, companyQuery);
    }
}
